export default {
    'edc.excel.tableInsertLeftCol': function () {
        const sheet = this.workbook.getActiveSheet();
        const row = sheet.getActiveRowIndex();
        const col = sheet.getActiveColumnIndex();
        const table = sheet.tables.find(row, col);
        if (table) {
            console.log(1, col - 1);
            let actionName = 'edc.excel.tableInsertCol';
            if(table.name().startsWith("custom")) {
                actionName = 'edc.excel.custableInsertCol';
            }
            this.workbook.commandManager().execute({
                autoFitType: GC.Spread.Sheets.AutoFitType.cell,
                cmd: actionName,
                sheet,
                sheetName: sheet.name(),
                col: col - 1,
                table,
                type:'left'
            });
        }
    }, 'edc.excel.tableInsertRightCol': function () {
        const sheet = this.workbook.getActiveSheet();
        const row = sheet.getActiveRowIndex();
        const col = sheet.getActiveColumnIndex();
        const table = sheet.tables.find(row, col);
        if (table) {
            console.log(2, col);
            let actionName = 'edc.excel.tableInsertCol';
            if(table.name().startsWith("custom")) {
                actionName = 'edc.excel.custableInsertCol';
            }
            this.workbook.commandManager().execute({
                autoFitType: GC.Spread.Sheets.AutoFitType.cell,
                cmd: actionName,
                sheet,
                sheetName: sheet.name(),
                col,
                table,
                type:'right'
            });
        }
    }, 'edc.excel.tableInsertTopRow': function () {
        const sheet = this.workbook.getActiveSheet();
        const row = sheet.getActiveRowIndex();
        const col = sheet.getActiveColumnIndex();
        const table = sheet.tables.find(row, col);
        if (table) {
            let actionName = 'edc.excel.tableInsertRow';
            if(table.name().startsWith("custom")) {
                actionName = 'edc.excel.custableInsertRow';
                
            }
            this.workbook.commandManager().execute({
                autoFitType: GC.Spread.Sheets.AutoFitType.cell,
                cmd: actionName,
                sheet,
                sheetName: sheet.name(),
                row: row,
                table,
                type:'top'
            });
        }
    }, 'edc.excel.tableInsertBottomRow': function () {
        const sheet = this.workbook.getActiveSheet();
        const row = sheet.getActiveRowIndex();
        const col = sheet.getActiveColumnIndex();
        const table = sheet.tables.find(row, col);
        if (table) {
            let actionName = 'edc.excel.tableInsertRow';
            if(table.name().startsWith("custom")) {
                actionName = 'edc.excel.custableInsertRow';
            }
            this.workbook.commandManager().execute({
                autoFitType: GC.Spread.Sheets.AutoFitType.cell,
                cmd: actionName,
                sheet,
                sheetName: sheet.name(),
                row: row + 1,
                table,
                type:'bottom'
            });
        }
    }, 'edc.excel.tableDeleteCol': function () {
        const sheet = this.workbook.getActiveSheet();
        const row = sheet.getActiveRowIndex();
        const col = sheet.getActiveColumnIndex();
        const table = sheet.tables.find(row, col);
        if (table) {
            let actionName = 'edc.excel.tableDeleteCol';
            if(table.name().startsWith("custom")) {
                actionName = 'edc.excel.custableDeleteCol';
            }
            this.workbook.commandManager().execute({
                autoFitType: GC.Spread.Sheets.AutoFitType.cell,
                cmd: actionName,
                sheet,
                sheetName: sheet.name(),
                col,
                table
            });
        }
    }, 'edc.excel.tableDeleteRow': function () {
        const sheet = this.workbook.getActiveSheet();
        const row = sheet.getActiveRowIndex();
        const col = sheet.getActiveColumnIndex();
        const table = sheet.tables.find(row, col);
        if (table) {
            let actionName = 'edc.excel.tableDeleteRow';
            if(table.name().startsWith("custom")) {
                actionName = 'edc.excel.custableDeleteRow';
            }
            this.workbook.commandManager().execute({
                autoFitType: GC.Spread.Sheets.AutoFitType.cell,
                cmd: actionName,
                sheet,
                sheetName: sheet.name(),
                row,
                table
            });
        }
    }
}